﻿@model LCTMoodle.Models.ViewModels.KhoaHocViewModel

@{
    //Lấy chức năng quyền
    string quyen = ((Dictionary<int, string>)Session["Quyen"])[Model.ma];
    
    bool coTheTaoBaiViet = quyen.IndexOf("|2|") != -1;
    
    //Nếu người dùng có thể tạo bài viết nhưng người dùng chưa đăng nhập (khách) thì ko cho đăng bài
    if (coTheTaoBaiViet)
    {
        coTheTaoBaiViet = (LCTMoodle.Models.ViewModels.NguoiDungViewModel)Session["NguoiDung"] != null;
    }
}

<link href="~/Content/froala/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="~/Content/froala/css/froala_editor.min.css" rel="stylesheet" type="text/css" />
<link href="~/Content/froala/css/themes/gray.min.css" rel="stylesheet" type="text/css" />
<script src="~/Content/froala/js/froala_editor.min.js"></script>
<script src="~/Content/froala/js/plugins/colors.min.js"></script>
<script src="~/Content/froala/js/plugins/font_size.min.js"></script>
<script src="~/Content/froala/js/plugins/lists.min.js"></script>

<script type="text/javascript">
    maKhoaHoc = '@Model.ma';

    $('#viet-bai').editable({
        inlineMode: false,
        buttons: ['bold', 'italic', 'underline', 'fontSize', 'color', 'align', 'formatBlock', 'insertOrderedList', 'insertUnorderedList', 'createLink', 'insertImage'],
        zIndex: 3,
        theme: 'gray',
        blockTags: ['p', 'pre', 'blockquote']
    });
</script>
<script src="~/Content/script/KhoaHoc/Nhom_DienDan.js"></script>
<link href="~/Content/css/KhoaHoc/Nhom_DienDan.css" type="text/css" rel="stylesheet" />

@if(coTheTaoBaiViet)
{
    <section class="compose-container">
        <form id="soan-bai-viet" class="compose" method="post" enctype="multipart/form-data" action="/BaiViet/KhoaHoc_Nhom_DienDan_ThemBaiViet" novalidate="novalidate">
            <input type="hidden" name="MaKhoaHoc" value="@Model.ma"/>
            <input name="TieuDe" class="title-editor" placeholder="Tiêu đề..." />
            <textarea id="viet-bai" name="NoiDung" class="editor" placeholder="Viết bài..."></textarea>
            <section class="attach-file-container">
                <section class="attach-file-button-container">
                    <i class="pe-7s-paperclip"></i>
                    <span class="text-attach-file">Thêm tập tin</span>
                </section>
                <section class="cancel-attach-file">
                    <i class="pe-7s-close-circle"></i>
                </section>
                <input class="attach-file" name="TapTin" type="file" hidden="hidden" />
            </section>
            <section class="article-type-container">
                <section class="add-article-type-button">
                    <i class="pe-7s-config"></i>
                    <span class="text-add-article-type">Thiết lập bài viết</span>
                </section>
                <section class="add-article-type-container">
                    <section class="add-article-type-type">
                        @Html.Action("KhoaHoc_Nhom_DienDan_LoaiBaiViet", "LoaiBaiViet")
                    </section>
                    <section class="add-article-type-time">
                        <select class="add-article-type-set-time">  
                            <option value="1">Áp dụng</option>
                            <option value="2">Đặt thời gian</option>
                        </select>
                        <input class="add-article-type-date-setting" type="date" />
                        <input class="add-article-type-time-setting" type="time" />
                    </section>
                    <section class="action-add-article-type">
                        <section class="accept-add-article-type">
                            <i class="pe-7s-check"></i>
                            <span>Thêm</span>
                        </section>
                        <section class="decline-add-article-type">
                            <i class="pe-7s-close-circle"></i>
                            <span>Hủy</span>
                        </section>
                    </section>
                </section>
                <section class="current-article-type">
                    <input type="hidden" name="LoaiBaiViet" value="" />                
                </section>
            </section>
            <section class="post-button-container">
                <i class="pe-7s-check"></i>
                <input type="submit" value="Đăng" class="post-button" />
            </section>            
        </form>
    </section>
}
<section id="dien-dan-bai-viet" class="article-container">
    <!--Chứa bài viết ajax-->
</section>
<section id="tai-them-bai-viet">
    &nbsp;
</section>